package com.bawei.mine.model

import com.bawei.common.model.BaseRepository
import com.bawei.mine.api.MineServiceApi
import com.bawei.mine.entity.Data
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class MineRepository @Inject constructor(private val mineServiceApi: MineServiceApi)  :BaseRepository<MineServiceApi>(){


    suspend fun loadAllOrders(category_id :Int ,currentPage :Int ,pageSize:Int) : Flow<List<Data>> {


        return flow {
            val result =   mineServiceApi.loadAllOrders(category_id,currentPage,pageSize)
            if (result.code==200){
                emit(result.data)
            }
            else{
                emit(listOf())
            }
        }


    }

}